2-Wire SPI ISO Click
2-Wire SPI ISO Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Nov 2023.
- Type : SPI type
Software Support
Example Description
This example demonstrates the use of a 2-Wire SPI ISO Click board by showing the communication between the two Click boards (Slave and Master). That is performed by sending commands to a 2-Wire SPI ISO Click (Slave) to read the device ID of a Accel 22 Click board connected to the 2-Wire SPI ISO Click (Master).
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.2WireSPIISO
Example Key Functions
- c2wirespiiso_cfg_setup Config Object Initialization function.
void c2wirespiiso_cfg_setup(c2wirespiiso_cfg_t *cfg)
2-Wire SPI ISO configuration object setup function.
2-Wire SPI ISO Click configuration object.
Definition c2wirespiiso.h:134
- c2wirespiiso_init Initialization function.
err_t c2wirespiiso_init(c2wirespiiso_t *ctx, c2wirespiiso_cfg_t *cfg)
2-Wire SPI ISO initialization function.
2-Wire SPI ISO Click context object.
Definition c2wirespiiso.h:114
- c2wirespiiso_default_cfg Click Default Configuration function.
void c2wirespiiso_default_cfg(c2wirespiiso_t *ctx)
2-Wire SPI ISO default configuration function.
- c2wirespiiso_write This function writes a desired number of data bytes by using SPI serial interface.
err_t c2wirespiiso_write(c2wirespiiso_t *ctx, uint8_t *data_in, uint8_t in_len)
2-Wire SPI ISO write function.
- c2wirespiiso_read This function reads a desired number of data bytes by using SPI serial interface.
err_t c2wirespiiso_read(c2wirespiiso_t *ctx, uint8_t *data_out, uint8_t out_len)
2-Wire SPI ISO read function.
- c2wirespiiso_get_bne_pin This function returns the RX buffer not empty (BNE) pin logic state.
uint8_t c2wirespiiso_get_bne_pin(c2wirespiiso_t *ctx)
2-Wire SPI ISO get bne pin function.
Application Init
Initializes the driver and performs the Click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define C2WIRESPIISO_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition c2wirespiiso.h:97
void application_init(void)
Definition main.c:49
Application Task
Reads and checks the device ID of a Accel 22 Click board connected to the 2-Wire SPI ISO (Master) Click, and displays the results on the USB UART approximately once per second.
{
Delay_ms ( 1000 );
}
void c2wirespiiso_get_accel22_id(c2wirespiiso_t *ctx)
2-Wire SPI ISO get Accel 22 ID function.
Definition main.c:103
void application_task(void)
Definition main.c:80
Note
The communication topology is as follows:
- MCU <-> 2-Wire SPI ISO Click (Slave) <-> 2-Wire SPI ISO Click (Master) <-> Accel 22 Click
The Master/Slave selection is done via on-board SMD jumpers. The Master Click board must be powered up with a 3V3 and 5V power supply externally. Also the DIS must be pulled down on Master Click board to enable the device.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.